//
//  DZMReadPageModel.swift
//  poetry
//
//  Created by YL-Hong on 2023/1/3.
//

import Foundation

class DZMReadPageModel: NSObject {
    
    // MARK: 常用属性
    /// 当前页内容
    var content:NSAttributedString!
    
    /// 纯文本
    var pureContent:String = ""
    
    /// 当前页范围
    var range:NSRange!
    
    /// 当前内容Size (目前主要是(滚动模式 || 长按模式)使用)
    var contentSize:CGSize = CGSize.zero
    
    /// 获取显示内容(考虑可能会变换字体颜色的情况)
    var showContent:NSAttributedString! {
        
//        let textColor = Note_Text_Content_Color_070707
        let tempShowContent = NSMutableAttributedString(attributedString: content)
//        tempShowContent.addAttributes([.foregroundColor : textColor], range: NSMakeRange(0, content.length))
        return tempShowContent
    }
    
    /// 诗词id
    var poetry_id:Int = 0
    var poetryName:String = ""
    var poetryDynasty:String = ""
    var poetryAuthor:String = ""
    var author_id:Int = 0
    
    var isPinyin:Bool = false
    
    static func setpageModel(content:NSAttributedString,
                             range:NSRange,
                             contentSize:CGSize,
                             poetry_id:Int,
                             poetryName:String,
                             poetryDynasty:String,
                             poetryAuthor:String,
                             author_id:Int,
                             pureContent:String = "",
                             isPinyin:Bool = false
    ) ->DZMReadPageModel{
        
        let model = DZMReadPageModel()
        model.content = content
        model.range = range
        model.contentSize = contentSize
        
        model.poetry_id = poetry_id
        model.poetryName = poetryName
        model.poetryDynasty = poetryDynasty
        model.poetryAuthor = poetryAuthor
        model.author_id = author_id
        
        model.pureContent = pureContent
        model.isPinyin = isPinyin
        
        return model
    }
    
}

class pinyinRangeModel:NSObject {
  
    var start:Int = 0
    var end:Int = 0
    
    var range: NSRange {
        return NSRange(location: start, length: end-start)
    }
    var originalIndex:Int = 0
}
